package java44th.group.controller.admin.feedback;

import java44th.group.bean.common.BasePageInfo;
import java44th.group.bean.common.CommonData;
import java44th.group.bean.po.MarketFeedback;
import java44th.group.bean.admin.vo.BaseRespVo;
import java44th.group.service.admin.feedback.FeedbackService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName project-second
 * @Descriptiom TODO
 * @Aurhor: 蔡文强
 * @Since: 2022/10/12 21:24
 */
@RestController
@RequestMapping("admin/feedback")
public class FeedbackController {

    @Autowired
    FeedbackService feedbackService;

    @RequiresPermissions("*")
    @RequestMapping(value = "list", method = RequestMethod.GET)
    public BaseRespVo list(BasePageInfo basePageInfo, String username, String id) {

        Integer integerId = null;
        if (id != null) {
            try {
                integerId = Integer.parseInt(id);
            } catch (Exception e) {
                return BaseRespVo.error(400, "请输入正确的id值");
            }
        }
        CommonData<MarketFeedback> marketFeedbackCommonData = feedbackService.list(basePageInfo, username, integerId);
        return BaseRespVo.ok(marketFeedbackCommonData);
    }

}
